<extend name="base/common"/>
<block name="style">
<style>.layui-form-label{width:120px !important}</style>
</block>
<block name="header"></block>
<block name="body">
<div class="layui-card layadmin-header">
	<div class="layui-breadcrumb" style="visibility: visible;">
		<a href="">首页</a>
		<a href=""><cite>{$title}</cite></a>
	</div>
</div>

<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form form-container" id="form1" action="__SELF__" method="post">
				<input type="hidden" name="id" id="id" value="{$data.id}"/>
				<input type="hidden" name="pid" id="pid" value="<notempty name="data">{$data.qr_pid}<else/>{$pdata.id}</notempty>" />
				<input type="hidden" name="uid" value="{$data.uid}"/>
				<div class="layui-form-item">
					<label class="layui-form-label">子码标题</label>
					<div class="layui-input-inline" style="width:70%">
						<input type="text" name="title" required="" lay-verify="required" value="{$data.title}" autocomplete="off" placeholder="{$data.title}" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">排序</label>
					<div class="layui-input-inline" style="width:70%">
						<input type="text" name="sort" lay-verify="required" value="{$data.sort}" autocomplete="off" placeholder="排序" class="layui-input">
					<div class="layui-form-mid layui-word-aux">子码显示的顺序，从小到大，依次显示</div>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">已扫描次数</label>
					<div class="layui-input-inline" style="width:70%">
						<input type="text" name="scan_count" lay-verify="required" value="<notempty name='data.scan_count'>{$data.scan_count}<else/>0</notempty>" autocomplete="off" placeholder="扫描次数" class="layui-input">
						<div class="layui-form-mid layui-word-aux">新增时，默认0次，当扫描次数达到最大次数后，可修改此值，让二维码重新显示，但是会导致统计错乱</div>
					</div>
				</div>

				<switch name="pdata.type_mode">
	                <case value="1">
	                	<input type="hidden" name="qr_type" value="1" title="图片" />
	                    <div class="layui-form-item cg cg1">
							<label class="layui-form-label">二维码上传</label>
							<div class="layui-input-inline" style="width:70%">
								<a id="qr_img_id" class="layui-btn layui-btn-sm" >上传图片</a>
								<input type="hidden" id="url" name="qr_img" value="{$data['qr_img']}"/>
								<div class="upload_file" style="margin-top:10px;display:block;overflow:hidden;">
									<notempty name="data['qr_img']">
										<p id="">
                                          <if condition="is_numeric($data['qr_img'])"><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|get_cover='path'}"><else/><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|str_replace='./','/',###}" ></if>
                                      	</p>
									<else/>
										<p id=""><img src="" id="upload_qr_img" style="max-width:30%"/></p>
									</notempty>
								</div>
							</div>
						</div>
	                </case>
	                <case value="2">
	                	<input type="hidden" name="qr_type" value="1" title="图片" />
	                    <div class="layui-form-item">
							<label class="layui-form-label">城市</label>
	                        {:hook('j_china_city',array('province'=>$data["qr_province"],'city'=>$data["qr_city"],'district'=>$data["qr_district"]))}
	                        <div class="layui-form-mid layui-word-aux">必须设置到第二个市级或者省级，才能生效</div>
	                    </div>

	                    <div class="layui-form-item cg cg1">
							<label class="layui-form-label">二维码上传</label>
							<div class="layui-input-inline" style="width:70%">
								<a id="qr_img_id" class="layui-btn layui-btn-sm" >上传图片</a>
								<input type="hidden" id="url" name="qr_img" value="{$data['qr_img']}"/>
								<div class="upload_file" style="margin-top:10px;display:block;overflow:hidden;">
									<notempty name="data['qr_img']">
										<p id=""><if condition="is_numeric($data['qr_img'])"><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|get_cover='path'}"><else/><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|str_replace='./','/',###}" ></if></p>
									<else/>
										<p id=""><img src="" id="upload_qr_img" style="max-width:30%"/></p>
									</notempty>
								</div>
							</div>
						</div>
	                </case>
	                <case value="3">
	                	<div class="layui-form-item">
							<label class="layui-form-label">类型</label>
							<div class="layui-input-inline" style="width:70%">
								<input type="radio" name="qr_type" value="1" title="图片" <eq name="data.qr_type" value="1">checked</eq>>
								<input type="radio" name="qr_type" value="2" title="链接" <eq name="data.qr_type" value="2">checked</eq>>
								<input type="radio" name="qr_type" value="3" title="文本" <eq name="data.qr_type" value="3">checked</eq>>
							</div>
							<div class="layui-form-mid layui-word-aux">必须选一个，然后上传对应资源</div>
						</div>

	                    <div class="layui-form-item cg cg1">
							<label class="layui-form-label">二维码上传</label>
							<div class="layui-input-inline" style="width:70%">
								<a id="qr_img_id" class="layui-btn layui-btn-sm" >上传图片</a>
								<input type="hidden" id="url" name="qr_img" value="{$data['qr_img']}"/>
								<div class="upload_file" style="margin-top:10px;display:block;overflow:hidden;">
									<notempty name="data['qr_img']">
										<p id=""><if condition="is_numeric($data['qr_img'])"><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|get_cover='path'}"><else/><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|str_replace='./','/',###}" ></if></p>
									<else/>
										<p id=""><img src="" id="upload_qr_img" style="max-width:30%"/></p>
									</notempty>
								</div>
							</div>
						</div>

						<div class="layui-form-item cg cg2">
							<label class="layui-form-label">链接</label>
							<div class="layui-input-inline" style="width:70%">
							  <input name="qr_link" placeholder="链接，带http://，如：http://www.baidu.com" class="layui-input" value="{$data.qr_link}" />
							</div>
						</div>

						<div class="layui-form-item cg cg3">
							<label class="layui-form-label">文本</label>
							<div class="layui-input-inline" style="width:70%">
								{:W('Common/Ueditor/editor',array('qr_text','qr_text',$data['qr_text'],"100%","300px","toolbars:[['source','|','bold','italic','underline','fontsize','forecolor', 'backcolor','|','justifyleft','justifycenter', 'justifyjustify', 'justifyright','|','fontfamily','|','map','emotion','insertimage']]"))}
							  <!-- <textarea name="qr_text" placeholder="文本" class="layui-textarea">{$data.qr_text}</textarea> -->
							</div>
						</div>
	                </case>
	                <case value="4">
	                	<input type="hidden" name="qr_type" value="1" title="图片" />
	                    <div class="layui-form-item cg cg1">
							<label class="layui-form-label">二维码上传</label>
							<div class="layui-input-inline" style="width:70%">
								<a id="qr_img_id" class="layui-btn layui-btn-sm" >上传图片</a>
								<input type="hidden" id="url" name="qr_img" value="{$data['qr_img']}"/>
								<div class="upload_file" style="margin-top:10px;display:block;overflow:hidden;">
									<notempty name="data['qr_img']">
										<p id=""><if condition="is_numeric($data['qr_img'])"><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|get_cover='path'}"><else/><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|str_replace='./','/',###}" ></if></p>
									<else/>
										<p id=""><img src="" id="upload_qr_img" style="max-width:30%"/></p>
									</notempty>
								</div>
							</div>
						</div>
	                </case>
	                <case value="5">
	                	<input type="hidden" name="qr_type" value="1" title="图片" />
	                	<div class="layui-form-item">
							<label class="layui-form-label">机型</label>
							<div class="layui-input-inline" style="width:70%">
								<input type="radio" name="qr_mob_type" value="1" title="安卓" <eq name="data.qr_mob_type" value="1">checked</eq>>
								<input type="radio" name="qr_mob_type" value="2" title="IOS" <eq name="data.qr_mob_type" value="2">checked</eq>>
							</div>
							<div class="layui-form-mid layui-word-aux">必须选一个，然后上传对应资源</div>
						</div>
	                    <div class="layui-form-item cg cg1">
							<label class="layui-form-label">二维码上传</label>
							<div class="layui-input-inline" style="width:70%">
								<a id="qr_img_id" class="layui-btn layui-btn-sm" >上传图片</a>
								<input type="hidden" id="url" name="qr_img" value="{$data['qr_img']}"/>
								<div class="upload_file" style="margin-top:10px;display:block;overflow:hidden;">
									<notempty name="data['qr_img']">
										<p id=""><if condition="is_numeric($data['qr_img'])"><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|get_cover='path'}"><else/><img id="upload_qr_img" style="max-width:30%" src="{$data.qr_img|str_replace='./','/',###}" ></if></p>
									<else/>
										<p id=""><img src="" id="upload_qr_img" style="max-width:30%"/></p>
									</notempty>
								</div>
							</div>
						</div>
	                </case>
	            </switch>

				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn-sm layui-btn" lay-submit="" lay-filter="*">立即提交</button>
						<a onclick="javascript:history.go(-1);" class="layui-btn-sm layui-btn layui-btn-primary" >返回上一页</a>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>


<script type="text/javascript">
	layui.use('upload', function(){
		var upload = layui.upload;
		upload.render({
			url: '{:U("home/File/uploadPicture",array("session_id"=>session_id()))}'
			,elem: '#qr_img_id' //指定原始元素，默认直接查找class="layui-upload-file"
			,method: 'post' //上传接口的http类型
			,accept: 'images'
			,field: 'qr_img_id'
			,before: function(input){
				//layer.msg('文件上传中', {icon: 16, fixed: true, offset: '80%', time:2000});
				layer.load(2, {shade: false});
			}
			,done: function(res, index, upload){
				layer.closeAll('loading'); //关闭loading
				upload_qr_img.src = res.data.qr_img_id.path;
				$("[name='qr_img']").val(res.data.qr_img_id.id);
			}
			,error: function(res, index, upload){
				layer.closeAll('loading'); //关闭loading
				layer.msg(res.info, {icon: 2, fixed: true, offset: '80%', time:1000});
			}
		});
	});
</script>
</block>